<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>案例4</title>
    <style>
        #asd {
            display: none;
            position: absolute;
        }
        
        div {
            height: 63px;
        }
        
        #img {
            width: 20px;
            border: 1px solid black;
            float: left;
            background: url(./res04/ico.png) no-repeat;
            background-size: cover;
        }
        
        ul {
            list-style: none;
            margin: 0;
            padding: 0;
        }
        
        ul li {
            display: block;
            width: 100%;
            padding: 0;
            margin: 0;
            background-color: blanchedalmond;
            color: black;
        }
        
        ul li:hover {
            background-color: white;
        }
    </style>

</head>

<body style="width: 100%;height: 900px;">
    <div id="asd" style="width: 80px;">
        <div id="img">

        </div>
        <div style="width: 60px;border: 1px solid black;">
            <ul>
                <li>剪切</li>
                <li>复制</li>
                <li>粘贴</li>
            </ul>
        </div>
    </div>
</body>

</html>
<Script>
    document.oncontextmenu = function(ev) {
        var oEvent = ev || event;
        var asd = document.querySelector("#asd")
        asd.style.display = 'block';

        asd.style.left = oEvent.clientX + 'px';

        asd.style.top = oEvent.clientY + 'px';
        return false;
    }
    document.onclick = function() {

        var asd = document.querySelector("#asd")

        asd.style.display = 'none';

    };
</Script>